package com.schoolvisitors.enums;

import lombok.Getter;

@Getter
public enum RoleEnum {
    USER_ROLE(1),
    ADMIN(2);

    private final Integer code;
    RoleEnum(int code) {
        this.code = code;
    }
    public static RoleEnum fromCode(int roleCode) {
        for (RoleEnum role : values()) {
            if (role.getCode() == roleCode) {
                return role;
            }
        }
        throw new IllegalArgumentException("无效的角色代码: " + roleCode);
    }
}
